//
//  NSMutableArray+LogAddObject.m
//  RunTime
//
//  Created by 宜必鑫科技 on 2017/11/8.
//  Copyright © 2017年 宜必鑫科技. All rights reserved.
//

#import "NSMutableArray+LogAddObject.h"
// 你可以重写某个方法而不用继承，同时还可以调用原先的实现
@implementation NSMutableArray (LogAddObject)

+(void)load
{
//    Method originalM = class_getInstanceMethod(NSClassFromString(@"__NSArrayM"), @selector(addObject:));
//    Method exchangeM = class_getInstanceMethod(NSClassFromString(@"__NSArrayM"), @selector(logAddObject:));
//    method_exchangeImplementations(originalM, exchangeM);
}

/**
   系统应该调用了很多次这个方法
 */
- (void)logAddObject:(id)aObject
{
    if ([aObject isKindOfClass:[NSString class]])
        NSLog(@"logAddObject: %@",aObject);
    [self logAddObject:aObject];
}
@end
